<form class="layui-form seller-form" action="">
    <div class="layui-form-item">
        <div class="layui-inline">
            <div class="layui-input-inline seller-inline-3" style="width: 180px;">
                <select name="select_state" lay-verify="" >
                    <option value="">Select State</option>
                    <option value="create_card">create_card</option>
                    <option value="card_inc">card_inc</option>
                    <option value="card_dec">card_dec</option>
                    <option value="card_cancel">card_cancel</option>
                    <option value="card_full">card_full</option>
                    <option value="user_card_full">user_card_full</option>
                </select>
            </div>
        </div>
        <div class="layui-inline" style="padding-left: 5px;">
            <input type="text" name="user_name" lay-verify="title" placeholder="Input User Name" autocomplete="off"
                   class="layui-input" style="width: 200px;">
        </div>
        <div class="layui-inline">
            <input type="text" name="datetime" id="datetime" placeholder="start_time _ end_time"
                   autocomplete="off" class="layui-input" style="width: 200px;">
        </div>
        <div class="layui-inline">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="*"><i class="iconfont icon-chaxun"></i>Search</button>
            </div>
        </div>
    </div>
</form>
<div class="table-body">
    <table id="balanceTable" lay-filter="balanceTable"></table>
</div>
<script>
    layui.use(['form', 'laydate', 'table',], function () {
        var laydate = layui.laydate,
            form = layui.form,
            table = layui.table; //表格
        //时间插件
        laydate.render({
            elem: '#datetime',
            range: '_',
            format: 'yyyy-MM-dd'
        });
        table.render({
            elem: '#balanceTable',
            height: 'full-99',
            cellMinWidth: '80',
            totalRow: true,
            method: 'post',
            url: "{:url('serveLog')}",
            id: 'balanceTable',
            cols: [[
                { type: 'numbers'},
                { field: 'token',  align: 'left', title: 'TokenLog',width: 200},
                { field: 'username',  align: 'left', title: 'UserName',width: 200},
                { field: 'type',  align: 'left', title: 'State',width: 150},
                { field: '', align: 'left', title: 'Type' ,width:120,
                    templet: function (d) {
                        const is_success = d.is_success;
                        if(is_success == 1){
                            return '<font color="red">Error</font>';
                        }else{
                            return '<font color="green">Success</font>';
                        }
                    }
                },
                { field: 'card_token',  align: 'left', title: 'CardToken'},
                { align: 'center', title: 'CreateTime',width:160,
                    templet: function (d) {
                        return layui.util.toDateString(d.ctime * 1000, "yyyy-MM-dd HH:mm:ss");
                    }
                },
                { field: 'option', title: 'Action', align: 'center', width: 80,
                    templet: function (d) {
                        return '<a class="layui-btn layui-btn-xs SearchDetail" data-id="' + d.id + '">info</a>';
                    }
                }
            ]],
            page: true,
            limit: 20,
            limits: [20, 50, 100],
        });
        form.on('submit(*)', function (data) {
            layui.table.reload('balanceTable', {
                where: data.field
                , page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
        //余额编辑
        $(document).on('click', '.SearchDetail', function () {
            var id = $(this).attr('data-id');
            var select_year = $('#select_year').val();
            JsGet("{:url('showInfo')}?id="+ id, function(e){
                if(e.status == 1){
                    layer.open({
                        type: 1,
                        title: 'Log Info',
                        area: ['1000px', '600px'], //宽高
                        content: e.datas,
                        btn:['Close']
                    });
                }else{
                    layer.msg(e.msg);
                }
            });
        });
    });
</script>